export interface NoticeBookType {
  name: string | null;
  score: ScoreType;
  comment: any[];
}

interface ScoreType {
  averageScore: number | null;
  chinese: number | null;
  english: number | null;
  math: number | null;
  sport: number | null;
  totalScore: number | null;
}

const comment = [
  {
    user: 'headTeacher',
    detail:
      '文章语言通俗易懂，贴近生活实际，读来令人倍感亲切。文章开头新颖,具有先声夺人之效。使读者一见面就能对人物产生印象。',
  },
  {
    user: '语文老师',
    detail:
      '这篇文章充满了激情，从字里行间能体会到作者的喜爱之情。全文层次清晰，语句流畅。事例叙述生动，具体，趣味性强。且与前面的比喻一脉相承。最后，用寥寥数语表现出了自已的情感，令人感动。',
  },
];

export default {
  namespace: 'noticeBook',
  state: {
    name: null,
    score: {
      averageScore: null,
      chinese: null,
      english: null,
      math: null,
      sport: null,
      totalScore: null,
    },
    comment: comment,
  },
  reducers: {
    setInfo(state: NoticeBookType, { payload }: { payload: any }) {
      const { name, averageScore, chinese, english, math, sport, totalScore } = payload;
      // console.log('payload', payload);
      return {
        ...state,
        name,
        score: {
          averageScore,
          chinese,
          english,
          math,
          sport,
          totalScore,
        },
      };
    },
    setComment(state: NoticeBookType, { payload }: { payload: any }) {
      return {
        ...state,
        payload,
      };
    },
  },
  effects: {
    // ...
  },
  subscriptions: {
    // ...
  },
};
